package top.buyibuyi.course.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import top.buyibuyi.course.R;
import top.buyibuyi.course.service.UploadFileService;

import java.io.IOException;
import java.io.InputStream;

@RestController
@CrossOrigin
@RequestMapping("/teacher")
public class UploadFileController {

    @Autowired
    private UploadFileService uploadFileService;

    @PostMapping("/uploadExcel")
    public R uploadExcel(MultipartFile file) throws IOException {
        System.out.println(file.getOriginalFilename());
        uploadFileService.uploadExcel(file,uploadFileService);

        return R.ok();
    }
}
